﻿/********************************************
 * 
 * 使用场景：
 * 文本或其特效组件存在两种颜色状态时
 * 
 * 详：
 * 增加了文本的颜色控制
 * 增加了文本特效outline颜色控制
 * 只需要设置好不同状态的颜色
 * 
 * ***********************************************/

namespace UnityEngine.UI
{
    public class UIText : Text
    {

        public struct TextColor
        {
            public Color Normal;
            public Color Gray;
        }

        public Color colorNormal
        {
            get
            {
                return this.color;
            }
            set
            {
                this.color = value;
            }
        }
        public Color colorGray;

        private bool _hasOutline;
        public Outline outLine;
        public TextColor outlineColor;

        protected override void Awake()
        {
            base.Awake();
            outLine = this.GetComponent<Outline>();
            _hasOutline = outLine != null;
            if (_hasOutline)
            {
                outlineColor.Normal = outLine.effectColor;
                outlineColor.Gray = outLine.effectColor;
            }
        }

        public void SetGray(bool isGray)
        {
            this.color = isGray ? colorGray : colorNormal;
            if (_hasOutline)
                outLine.effectColor = isGray ? outlineColor.Gray : outlineColor.Normal;
        }
    }

}
